<?php
namespace Home\Controller;
class RelationController extends AdminController{

	private $_relation=null;	//操作


	public function __construct(){
		parent::__construct();
		$this->_relation=M('foucs');
	}
	//查询函数
	 public function chaxun(){
	 	$id=I('get.id/d');
	 	$uid=$_SESSION['love_user']['id'];
	 	$data=array('uid'=>$uid,'kid'=>$id);
	 	$temp=$this->_relation->where($data)->select();
	 	if(!empty($temp)){
	 		echo 1;
	 	}else{
	 		echo 0;
	 	}
	 }
  	//关注函数
	public function addFoucs(){
		$id=I('get.id/d');	//模拟前台点击哪个会员id
		$uid=$_SESSION['love_user']['id'];//获取session中的值
		$data=array('uid'=>$uid,'kid'=>$id);
		if($this->_relation->add($data)>0){
			echo 1;
		}else{
			echo 0;
		}
	}
	//取消关注
	public function delFoucs(){
		$id=I('get.id/d');	//模拟前台点击哪个会员id
		$uid=$_SESSION['love_user']['id'];//获取session中的值
		$data=array('uid'=>$uid,'kid'=>$id);
		if($this->_relation->where($data)->delete()>0){
			echo 1;
		}else{
			echo 0;
		}
	}

}